package br.com.bringme.models.user;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import br.com.bringme.models.Telefone;
import br.com.bringme.models.Pessoa;

@Entity
@Table(name = "bring_me.clientes")
@SequenceGenerator(name = "clientes_seq", sequenceName = "bring_me.clientes_id_cliente_seq")
public class Cliente extends Pessoa {

	@Id
	@GeneratedValue(generator = "clientes_seq", strategy = GenerationType.AUTO)
	@Column(name = "id_cliente")
	protected Integer id;

	@OneToMany(cascade = CascadeType.ALL)
	@JoinTable(name = "bring_me.usuarios_telefones", joinColumns = { @JoinColumn(name = "usuario") }, inverseJoinColumns = { @JoinColumn(name = "telefone") })
	protected Set<Telefone> telefones = new HashSet<Telefone>();

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Set<Telefone> getTelefones() {
		return telefones;
	}

	public void setTelefone(Set<Telefone> telefones) {
		this.telefones = telefones;
	}

	@Override
	public String toString() {
		return "Cliente [id=" + id + ", telefones=" + telefones + ", usuario=" + super.toString() + "]";
	}
}
